﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.ModelBinding;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.Unity;
using PharmacyBussinesEntities;
using PharmacyService;

namespace PharmacyWeb.Almacen
{
    public partial class frmListCategorias : System.Web.UI.Page
    {
        [Dependency]
        public ICategoriaService categoriaService { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            var accion = Request.QueryString["accion"];
            var idr = Request.QueryString["id"];
            if (accion != null && accion == "eliminar" && idr != null)
            {
                var idrr = Int32.Parse(idr);
                categoriaService.RemoveCategoria(idrr);
                Response.Redirect("frmListCategorias.aspx");
            }
        }
        public IEnumerable<Categoria> GetCategorias([Control("txtCriterio")]string criterio)
        {
            return categoriaService.GetFromCategorisByCriterio(criterio);
        }
    }
}